<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('trip_order_passenger_refund_details', function (Blueprint $table) {
            $table->id();
            $table->string('user_id')->comment('用户id');
            $table->string('refund_sn')->comment('退款单号');
            $table->string('order_sn')->comment('订单单号');
            $table->tinyInteger('type')->comment('退款项目类型 如:车票,保险费,购票手续费,坐席,票价差');
            $table->tinyInteger('trip_type')->default(0)->comment('出行类型 1 火车 2 飞机 3 酒店... ');
            $table->string('name')->comment('费用名称');
            $table->string('passenger_id', 50)->default('')->comment('如果存在乘客id 表示按乘客id 退款');
            $table->tinyInteger('sequence')->default(0)->comment('乘客序号');
            $table->unsignedDecimal('amount', 10, 2)->comment('金额');
            $table->string('out_trade_no')->default('')->comment('关联的支付单号');
            $table->timestamps();
            $table->index('refund_sn', 'idx_refundsn');
            $table->unique(['order_sn', 'passenger_id', 'sequence', 'type'], 'unique_passenger_type');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('trip_order_passenger_refund_details');
    }
};
